let fs=require('fs')
let path=require('path')
let express=require('express')

let app=express();

app.use(express.static(path.join(__dirname,"./public")))
app.use(express.json())

app.get('/',(req,res)=>{
    res.end(fs.readFileSync(path.join(__dirname,"./public/index.html")))
})

app.get('/user/keyword/:keyword',(req,res)=>{
    let {keyword}=req.params;
console.log(req.params);

    let all=JSON.parse(fs.readFileSync(path.join(__dirname, '/data.json'),'utf-8'))
    let run=all.filter(item=>item.name.includes(keyword))
    res.json(run)
}) 
app.listen(8000) 